<?php

    class groups_model extends CI_Model{

        function __construct()
        {
            parent::__construct();
        }

        function insert($data)
        {
            $this->db->insert('groups',$data);
            return $this->db->insert_id();
        }

        function view_all_groups($custom = NULL)
        {
            $q = '
            SELECT * from groups
            ';
            if(isset($custom))
            {
                $q.="WHERE custom = $custom";
            }

            $res = $this->db->query($q)->result_array();
            return $res;

        }

        function delete_group($group_ID)
        {
            $q="
            DELETE FROM groups
            WHERE ID = $group_ID
            ";
            $res = $this->db->query($q);
            return $res;
        }

    }

?>